package com.k8sops.backend.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类，处理跨域请求
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 注释掉此CORS配置，使用WebMvcConfig中的CorsFilter配置
        // registry.addMapping("/**")
        //         .allowedOrigins(
        //             "http://localhost:3001",
        //             "http://localhost:3000",
        //             "http://localhost:8080",
        //             "http://127.0.0.1:3000",
        //             "http://127.0.0.1:3001",
        //             "http://127.0.0.1:8080"
        //         )
        //         .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
        //         .allowedHeaders("*")
        //         .exposedHeaders("Authorization", "Content-Type", "X-Requested-With", "Accept",
        //                        "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers")
        //         .allowCredentials(true)
        //         .maxAge(3600);
    }
}
